package com.onlyphoto.onlymall.mvp.model

import com.onlyphoto.onlymall.api.Urls
import com.onlyphoto.onlymall.base.BaseModel
import com.onlyphoto.onlymall.base.BaseObserver
import com.onlyphoto.onlymall.bean.request.GoodsCondition
import com.onlyphoto.onlymall.bean.response.GoodsBean
import com.onlyphoto.onlymall.utils.ConfigUtil
import com.onlyphoto.onlymall.utils.RxTransformer


class MSearchImpl : BaseModel() {
    var url = ""
    fun requestTopSearch(baseObserver: BaseObserver<ArrayList<String>>) {
        url = ConfigUtil.instance.getUrl(Urls.TOP_SEARCH)
        apiService().topSearch(url)
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }

    fun requestGoods(condition: GoodsCondition, baseObserver: BaseObserver<ArrayList<GoodsBean>>) {
        url = ConfigUtil.instance.getUrl(Urls.GOODS_LIST)
        apiService().goods(url, condition.toMap())
                .compose(RxTransformer.switchSchedulers(this))
                .subscribe(baseObserver)
    }
}
